import request from '@/utils/request'

export const addItemToCart = (data) => {
  return request.post({
    url: '/user/cart/addItem',
    data
  })
}


// 获取购物车列表
export function getCartList() {
  return request.get({
    url: '/user/cart'
  })
}

// 获取勾选商品信息
export function getSelectedCart(data) {
  return request.post({
    url: '/user/cart/userCart',
    data
  })
}

// 增加商品数量
export function increaseQuantity(id) {
  return request.put({
    url: `/user/cart/addItem/${id}`
  })
}

// 减少商品数量
export function decreaseQuantity(id) {
  return request.put({
    url: `/user/cart/reduceItem/${id}`
  })
}

// 删除购物车商品
export function removeCartItems(itemIds) {
  return request.delete({
    url: '/user/cart/removeItems',
    data: itemIds
  })
} 